package com.lanren.familybookapp.base;

import android.view.View;

import com.lanren.common.app.ActivityStackManager;
import com.lanren.common.base.IPresenter;
import com.lanren.common.base.impl.BaseLazyFragment;
import com.lanren.common.interfaces.DialogClickListener;
import com.lanren.familybookapp.app.AppUserHelper;
import com.lanren.familybookapp.ui.user.view.LoginActivity;

/**
 * @ClassName BaseUiLazyFragment
 * @Description TODO
 * @Author chongheng.wang
 * @Date 2019/11/5 9:59
 * @Version 1.0
 */
public abstract class BaseUiLazyFragment<P extends IPresenter> extends BaseLazyFragment<P> {
    @Override
    public void showError(int code, String msg) {
        super.showError(code, msg);
        if (code == 130 || code == 140 || code == 150 || code == 10007) {
            showMessageDialog(msg, true, new DialogClickListener() {
                @Override
                public void onCancelClick(View v) {

                }

                @Override
                public void onConfirmClick(View v) {
                    AppUserHelper.getInstance().logout();
                    // 进行内存优化，销毁掉所有的界面
                    ActivityStackManager.getInstance().finishAllActivities();
                    startActivity(LoginActivity.class);
                }
            });
        } else {
            showMessage(msg);
        }
    }
}
